package com.probiz.estore.common.model.content.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.content.Advertisement;

/**
 * Advertisement Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AdvertisementTbl extends com.probiz.estore.core.model.BaseObject implements Serializable {

    protected Integer advertisementId;
	protected String advertisementName;
	protected Short contentType;
	protected String advertisementDetail;
	protected String url;
	protected String redirectUrl;
	protected BigDecimal width;
	protected BigDecimal height;
	protected Date startPublishTime;
	protected Date endPublishTime;
	protected Short isShow;
	protected Short status;
	protected Integer sortOrder;
	protected Integer createBy;
	protected Integer updateBy;
	protected Date createTime;
	protected Date updateTime;
	protected Integer version;

	public Integer getSortOrder() {
		return sortOrder;
	}
	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}
	
	
    protected com.probiz.estore.common.model.content.AdPositionType adPositionType;	
 
	protected java.util.Set productAdvertisements = new java.util.HashSet();

	/**
	 * Default Empty Constructor for class Advertisement
	 */
	public AdvertisementTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class Advertisement
	 */
	public AdvertisementTbl (
		 Integer in_advertisementId
        ) {
		this.setAdvertisementId(in_advertisementId);
    }

	

//	public java.util.Set getAdvertisementPositions () {
//		return advertisementPositions;
//	}	
//	
//	public void setAdvertisementPositions (java.util.Set in_advertisementPositions) {
//		this.advertisementPositions = in_advertisementPositions;
//	}

	public java.util.Set getProductAdvertisements () {
		return productAdvertisements;
	}	
	
	public void setProductAdvertisements (java.util.Set in_productAdvertisements) {
		this.productAdvertisements = in_productAdvertisements;
	}
    

	/**
	 * 
	 * @return Integer
     * @hibernate.id column="advertisementId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getAdvertisementId() {
		return this.advertisementId;
	}
	
	/**
	 * Set the advertisementId
	 */	
	public void setAdvertisementId(Integer aValue) {
		this.advertisementId = aValue;
	}	
	
//	/**
//	 * 
//	 * @return Integer
//	 */
//	public Integer getPromotionId() {
//		return this.getPromotion()==null?null:this.getPromotion().getPromotionId();
//	}
	
	/**
	 * Set the promotionId
	 */	
//	public void setPromotionId(Integer aValue) {
//	    if (aValue==null) {
//	    	promotion = null;
//	    } else{
//	        promotion = new com.probiz.estore.common.model.sales.Promotion(aValue);
//	        promotion.setVersion(new Integer(0));//set a version to cheat hibernate only
//	    } 
//	}	

	/**
	 * 
	 * @return String
	 * @hibernate.property column="advertisementName" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getAdvertisementName() {
		return this.advertisementName;
	}
	
	/**
	 * Set the advertisementName
	 * @spring.validator type="required"
	 */	
	public void setAdvertisementName(String aValue) {
		this.advertisementName = aValue;
	}	

	/**
	 * 
	 * @return Short
	 * @hibernate.property column="contentType" type="java.lang.Short" length="6" not-null="true" unique="false"
	 */
	public Short getContentType() {
		return this.contentType;
	}
	
	/**
	 * Set the contentType
	 * @spring.validator type="required"
	 */	
	public void setContentType(Short aValue) {
		this.contentType = aValue;
	}	

	/**
	 * 
	 * @return String
	 * @hibernate.property column="advertisementDetail" type="java.lang.String" length="512" not-null="false" unique="false"
	 */
	public String getAdvertisementDetail() {
		return this.advertisementDetail;
	}
	
	/**
	 * Set the advertisementDetail
	 */	
	public void setAdvertisementDetail(String aValue) {
		this.advertisementDetail = aValue;
	}	

	/**
	 * 
	 * @return String
	 * @hibernate.property column="url" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getUrl() {
		return this.url;
	}
	
	/**
	 * Set the url
	 * @spring.validator type="required"
	 */	
	public void setUrl(String aValue) {
		this.url = aValue;
	}	

	/**
	 * 
	 * @return String
	 * @hibernate.property column="redirectUrl" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getRedirectUrl() {
		return this.redirectUrl;
	}
	
	/**
	 * Set the redirectUrl
	 */	
	public void setRedirectUrl(String aValue) {
		this.redirectUrl = aValue;
	}	


	/**
	 * 
	 * @return java.math.BigDecimal
	 * @hibernate.property column="width" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
	 */
	public java.math.BigDecimal getWidth() {
		return this.width;
	}
	
	/**
	 * Set the width
	 */	
	public void setWidth(java.math.BigDecimal aValue) {
		this.width = aValue;
	}	

	/**
	 * 
	 * @return java.math.BigDecimal
	 * @hibernate.property column="height" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
	 */
	public java.math.BigDecimal getHeight() {
		return this.height;
	}
	
	/**
	 * Set the height
	 */	
	public void setHeight(java.math.BigDecimal aValue) {
		this.height = aValue;
	}	

	/**
	 * 
	 * @return java.util.Date
	 * @hibernate.property column="startPublishTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getStartPublishTime() {
		return this.startPublishTime;
	}
	
	/**
	 * Set the startPublishTime
	 */	
	public void setStartPublishTime(java.util.Date aValue) {
		this.startPublishTime = aValue;
	}	

	/**
	 * 
	 * @return java.util.Date
	 * @hibernate.property column="endPublishTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getEndPublishTime() {
		return this.endPublishTime;
	}
	
	/**
	 * Set the endPublishTime
	 */	
	public void setEndPublishTime(java.util.Date aValue) {
		this.endPublishTime = aValue;
	}	

	/**
	 * 
	 * @return Integer
	 * @hibernate.property column="createBy" type="java.lang.Integer" length="11" not-null="false" unique="false"
	 */
	public Integer getCreateBy() {
		return this.createBy;
	}
	
	/**
	 * Set the createBy
	 */	
	public void setCreateBy(Integer aValue) {
		this.createBy = aValue;
	}	

	/**
	 * 
	 * @return Integer
	 * @hibernate.property column="updateBy" type="java.lang.Integer" length="11" not-null="false" unique="false"
	 */
	public Integer getUpdateBy() {
		return this.updateBy;
	}
	
	/**
	 * Set the updateBy
	 */	
	public void setUpdateBy(Integer aValue) {
		this.updateBy = aValue;
	}	

	/**
	 * 
	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 
	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	
	public Short getIsShow() {
		return isShow;
	}
	public void setIsShow(Short isShow) {
		this.isShow = isShow;
	}
	/**
	 * 
	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="6" not-null="false" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * 
	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="11" not-null="false" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	


	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Advertisement)) {
			return false;
		}
		Advertisement rhs = (Advertisement) object;
		return new EqualsBuilder()
				.append(this.advertisementId, rhs.advertisementId)
								.append(this.advertisementName, rhs.advertisementName)
				.append(this.contentType, rhs.contentType)
				.append(this.advertisementDetail, rhs.advertisementDetail)
				.append(this.url, rhs.url)
				.append(this.redirectUrl, rhs.redirectUrl)
				.append(this.width, rhs.width)
				.append(this.height, rhs.height)
				.append(this.startPublishTime, rhs.startPublishTime)
				.append(this.endPublishTime, rhs.endPublishTime)
				.append(this.createBy, rhs.createBy)
				.append(this.updateBy, rhs.updateBy)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.status, rhs.status)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.advertisementId) 
								.append(this.advertisementName) 
				.append(this.contentType) 
				.append(this.advertisementDetail) 
				.append(this.url) 
				.append(this.redirectUrl) 
				.append(this.width) 
				.append(this.height) 
				.append(this.startPublishTime) 
				.append(this.endPublishTime) 
				.append(this.createBy) 
				.append(this.updateBy) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.status) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("advertisementId", this.advertisementId) 
								.append("advertisementName", this.advertisementName) 
				.append("contentType", this.contentType) 
				.append("advertisementDetail", this.advertisementDetail) 
				.append("url", this.url) 
				.append("redirectUrl", this.redirectUrl) 
				.append("width", this.width) 
				.append("height", this.height) 
				.append("startPublishTime", this.startPublishTime) 
				.append("endPublishTime", this.endPublishTime) 
				.append("createBy", this.createBy) 
				.append("updateBy", this.updateBy) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("status", this.status) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "advertisementId";
	}
	public com.probiz.estore.common.model.content.AdPositionType getAdPositionType() {
		return adPositionType;
	}
	public void setAdPositionType(
			com.probiz.estore.common.model.content.AdPositionType adPositionType) {
		this.adPositionType = adPositionType;
	}
	
	public void setAdPositionTypeId(Integer id){
		if(id == null){
			this.adPositionType = null;
		}
		else{
			adPositionType = new com.probiz.estore.common.model.content.AdPositionType(id);
			adPositionType.setVersion(Integer.valueOf(0));
		}
	}
	public Integer getAdPositionTypeId() {
        return this.adPositionType == null ? null : this.adPositionType.getAdPositionTypeId();
    }
}